package com.sc.VenusQueryBeta.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.sc.VenusQueryBeta.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Pop適配器
 */

public class VerSionInfoAdapter extends BaseAdapter {

    private final LayoutInflater mInflater;
    private List<String> stringList = new ArrayList<>();

    public VerSionInfoAdapter(Context mContext, List<List<String>> aboutSKBean) {
        stringList.clear();
//        if (stringList.size()==0) {
//            this.stringList = aboutSKBean;
//        }
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return stringList == null ? 0 : stringList.size();
    }

    @Override
    public Object getItem(int i) {
        return stringList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        final ViewHolder  viewHolder;
        if (view == null) {
            view = mInflater.inflate(R.layout.layout_version_item, null);
            viewHolder = new ViewHolder(view);
            viewHolder.tvInfo.setText(stringList.get(i));
            // 通过setTag()绑定ViewHolder和view
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        return view;
    }

    static class ViewHolder {
         TextView tvInfo;

         ViewHolder(View view) {
            tvInfo = view.findViewById(R.id.tv_info);
        }
    }
}
